<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Flutter InAppBrowser demo</title>
    <link rel="stylesheet" href="https://getbootstrap.com/docs/4.3/dist/css/bootstrap.min.css">
    <!-- <link rel="stylesheet" href="css/demo.css"> -->
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>

<body>
    <div class="main">
        <div class="content">
            <!-- <input /> -->
            <button style="background-color: aqua;" onclick="dianji()">给APP发消息</button>
        </div>

        <button style="background-color: aqua;margin-top: 20px">更改body背景颜色</button>

        <span style="margin-top:20px">接收到APP的消息:
            <span id="text"></span>
        </span>
    </div>

    <script>
        window.addEventListener("flutterInAppBrowserPlatformReady", function (event) {
            console.log("ready");

            window.flutter_inappbrowser.callHandler('handlerFoo').then(function (result) {
                console.log(result, typeof result);
                console.log(JSON.stringify(result), result.bar);
            });

            window.flutter_inappbrowser.callHandler('handlerFooWithArgs', 1, true, ['bar', 5], {
                foo: 'baz'
            }).then(function (result) {
                console.log(result, typeof result);
                console.log(JSON.stringify(result));
            });
        });

        function dianji() {
            window.flutter_inappbrowser.callHandler('test', 'hello', 1234).then(function (result) {
                console.log(result, typeof result);
                console.log(JSON.stringify(result), result);

            });
        }

        window.appSendJs = function (args) {

            console.log(args)
            document.getElementById('text').innerHTML = args
        }
    </script>
</body>

</html>